package com.yyq.common;

import java.time.Instant;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;

/**
 * @author yyq
 * @create 2021-08-03 20:36
 */
public class YYQ_instan {
    public static void main(String[] args) {
        //实例化 .now 本初子午线的标准时间
        Instant now = Instant.now();
        System.out.println(now);
        //添加时间偏移量
        OffsetDateTime offsetDateTime = now.atOffset(ZoneOffset.ofHours(8));
        System.out.println(offsetDateTime);

        //获取对应的毫秒数 1900-1-1-0-0
        System.out.println(now.toEpochMilli());

        //ofEpochMilli:通过给定毫秒数实例化
        Instant instant = Instant.ofEpochMilli(1627994412494L);
        System.out.println(instant);

    }
}
